layui.define(function (exports) {
    var a = layui.jquery,
        f = layui.form,
        t = layui.table,
        ly = layui.layer,

        T = {
            method: {
                // +----------------------------------------------------------------------
                // | 自定义顶部按钮方法
                // +----------------------------------------------------------------------
                top: {},
                // +----------------------------------------------------------------------
                // | 自定义右侧按钮方法
                // +----------------------------------------------------------------------
                right: {
                    /** 会员登录 */
                    login: function (data, tool, obj) {
                        ly.confirm('确定要登录吗？', {title: '请确认'}, function (index) {
                            layui.listen.method.load();
                            a.post(tool.url, {id: data.id, tableUniqueTitle: tool.unity_title}, function (data) {
                                ly.closeAll();
                                if (data.code === 1) {
                                    parent.layer.open({
                                        type: 2,
                                        area: ['390px', a(window).height() < 800 ? (90 + '%') : (800 + 'px')],
                                        anim: 2,
                                        offset: 'rb',
                                        shade: 0,
                                        title: '<a  href="' + data.data.url + '" target="_blank" >当前登录 《 ' + data.data.code + '》 右键可选择新窗口打开</a>',
                                        content: "" + data.data.url + "",
                                    });
                                } else {
                                    notify.error(data.msg);
                                }
                            })
                        });
                    },
                    deliver: function (data, tool, obj) {

                        ly.open({
                            type: 2,
                            title: '订单发货',
                            shadeClose: true,
                            shade: 0.8,
                            area: ['1000px'],
                            content: tool.url + '&id=' + data.id,
                            success: function (layero, index, that) {
                                ly.iframeAuto(index);
                                that.offset();
                            },
                            btn: ['确认', '取消'],
                            btn2: function (index) {
                                ly.close(index);
                            },
                            btn1: function (index) {
                                var body = ly.getChildFrame('body', index);
                                layui.listen.method.load();
                                a.post(tool.url, body.find('.layui-form').serialize(), function (data) {
                                    ly.closeLast('dialog');
                                    if (data.code === 1) {
                                        ly.msg(data.msg, {time: 1000}, function () {
                                            ly.close(index);
                                            location.reload()
                                        });
                                    } else {
                                        ly.msg(data.msg);
                                    }
                                });
                                return false
                            },
                        });
                    }
                }
            },
        };

    exports('handle', T);
});